﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace BioCyber_Infection
{
    class SessionScreen
    {
        #region Begin of Declaration

        /// <Fonte>
        /// Font Arial; Tamanho 14; Italic=false;  Bold=false
        /// </Fonte>
        SpriteFont titleFont;
        Rectangle backGameButtonSource;
        Texture2D backgroundImage;

        /// <GameWindow>
        /// Objeto gerenciados do GameWindow
        /// </GameWindow>
        GameWindow window;

        #endregion
        //################//


        #region Constructor
        public SessionScreen(GameWindow gameWindow, ContentManager content)
        {
            this.window = gameWindow;
            this.backgroundImage = content.Load<Texture2D>("background");
            this.titleFont = content.Load<SpriteFont>("SpriteFont1");

            backGameButtonSource = new Rectangle((int)(window.ClientBounds.Width * 0.05), 250, 50, 25);
        }
        #endregion

        /// <Drawing...>
        /// Método usado para desenhar o Menu da tela de Sessão
        /// </DRAW Summary>
        #region Draw Menu Screen
        public void DrawMenuScreen(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(backgroundImage, new Rectangle(0, 0, window.ClientBounds.Width, window.ClientBounds.Height), Color.White);

            spriteBatch.DrawString(this.titleFont, "Session Menu", new Vector2((float)(window.ClientBounds.Width * 0.05), 50/*(float)(window.ClientBounds.Height*0.2)*/), Color.White);
            string message = string.Empty;

            message = "Press A to create a Session\n" + 
                      "Press B to Join Session";

            spriteBatch.DrawString(titleFont, message, new Vector2((int)(window.ClientBounds.Width * 0.05), 125), Color.Yellow);
            //spriteBatch.DrawString(titleFont, "Back", new Vector2((float)(backGameButtonSource.X), (float)(backGameButtonSource.Y)), Color.White);
        }
        #endregion

        /// <Updating...>
        /// Este update testa se estamos na tela de login da Live.
        /// Case o jogo permaneça 5 segundos sem um usuário logado, o próprio sistema irá sugerir a lista de usuários
        /// </summary>
        #region Update
        public void Update(GameTime gameTime)
        {
            Engine.currentState = Engine.gameState.LIVE;

            if (Mouse.GetState().LeftButton == ButtonState.Pressed && Engine.currentState == Engine.gameState.SESSIONSCREEN)
            {
                if (Engine.isColliding(backGameButtonSource, Engine.mousePos))
                {
                    Engine.currentState = Engine.gameState.MAINMENU;
                }
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.Escape) && Engine.currentState == Engine.gameState.SESSIONSCREEN)
            {
                Engine.currentState = Engine.gameState.MAINMENU;
            }
        }
        #endregion
    }
}
